home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Technical Documentation / Sample Code / DTS.Lib & Samples / Zippo / DoEvent.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-22  |  3.5 KB  |  176 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:        DoEvent.c
  5. ** Written by:    Eric Soldan
  6. **
  7. ** Copyright © 1990-1991 Apple Computer, Inc.
  8. ** All rights reserved.
  9. */
  10.  
  11.  
  12.  
  13. /*****************************************************************************/
  14.  
  15.  
  16.  
  17. #include "App.h"            /* Get the application includes/typedefs, etc.    */
  18. #include "App.Common.h"        /* Get the stuff in common with rez.            */
  19. #include "App.protos.h"        /* Get the prototypes for application.            */
  20.  
  21. #ifndef __CTLHANDLER__
  22. #include "CtlHandler.h"
  23. #endif
  24.  
  25. #ifndef __DESK__
  26. #include <Desk.h>
  27. #endif
  28.  
  29. #ifndef __DISKINIT__
  30. #include <DiskInit.h>
  31. #endif
  32.  
  33. #ifndef __ERRORS__
  34. #include <Errors.h>
  35. #endif
  36.  
  37. #ifndef __MENUS__
  38. #include <Menus.h>
  39. #endif
  40.  
  41. #ifndef __TEXTEDITCONTROL__
  42. #include "TextEditControl.h"
  43. #endif
  44.  
  45. #ifndef __TOOLUTILS__
  46. #include <ToolUtils.h>
  47. #endif
  48.  
  49. #ifndef __UTILITIES__
  50. #include "Utilities.h"
  51. #endif
  52.  
  53.  
  54.  
  55. /*****************************************************************************/
  56.  
  57.  
  58.  
  59. extern Cursor    *gCursorPtr;
  60.     /* See the file Window2.c for comments about this global. */
  61.  
  62.  
  63.  
  64. /*****************************************************************************/
  65. /*****************************************************************************/
  66.  
  67.  
  68.  
  69. /* Do the right thing for an event.  Determine what kind of event it is, and
  70. ** call the appropriate routines. */
  71.  
  72. #pragma segment Main
  73. void    DoEvent(EventRecord *event)
  74. {
  75.     WindowPtr        window;
  76.     Point            pt;
  77.     OSErr            err;
  78.     TEHandle        teHndl;
  79.  
  80.     switch(event->what) {
  81.  
  82.         case nullEvent:
  83.             DoIdleTasks(event);
  84.             break;
  85.  
  86.         case mouseDown:
  87.             DoMouseDown(event);
  88.             break;
  89.  
  90.         case autoKey:
  91.         case keyDown:                    /* Check for menukey equivalents. */
  92.             DoKeyDown(event);
  93.             break;
  94.  
  95.         case activateEvt:
  96.             gCursorPtr = nil;            /* Force recalculation of the cursor. */
  97.             DoActivate((WindowPtr)event->message);
  98.             break;
  99.  
  100.         case updateEvt:
  101.             DoUpdate((WindowPtr)event->message);
  102.             break;
  103.  
  104.         case kHighLevelEvent:
  105.             gCursorPtr = nil;            /* Force recalculation of the cursor. */
  106.             DoHighLevelEvent(event);
  107.             break;
  108.  
  109.         case osEvt:
  110.             gCursorPtr = nil;            /* Force recalculation of the cursor. */
  111.             switch ((event->message >> 24) & 0xFF) {
  112.                     /* Must logical and with 0xFF to get only low byte. */
  113.                     /* High byte of message. */
  114.  
  115.                 case mouseMovedMessage:
  116.                     break;
  117.  
  118.                 case suspendResumeMessage:
  119.                         /* Suspend/resume is also an activate/deactivate. */
  120.                     gInBackground = !((event->message) & resumeFlag);
  121. #if VH_VERSION
  122.                     CTEConvertClipboard((event->message) & convertClipboardFlag, !gInBackground);
  123. #endif
  124.                     DoActivate(FrontWindow());
  125.                     HiliteWindows();
  126.                     break;
  127.             }
  128.             break;
  129.  
  130.         case diskEvt:
  131.             gCursorPtr = nil;            /* Force recalculation of the cursor. */
  132.             if (HiWord(event->message) != noErr) {
  133.                 SetPt(&pt, kDILeft, kDITop);
  134.                 err = DIBadMount(pt, event->message);
  135.             }
  136.             break;        /* It is not a bad idea to at least call DIBadMount
  137.                         ** in response to a diskEvt, so that the user can
  138.                         ** format a floppy. */
  139.     }
  140.  
  141.     DoCursor();
  142.     DoAdjustMenus();
  143.  
  144.     if (teHndl = CTEFindActive(nil)) {
  145.         BeginContent(window = (*teHndl)->inPort);
  146.         CTEIdle();
  147.         EndContent(window);
  148.     }
  149. }
  150.  
  151.  
  152.  
  153. /*****************************************************************************/
  154.  
  155.  
  156.  
  157. /* This is called when a window is activated or deactivated. */
  158.  
  159. #pragma segment Main
  160. void    DoActivate(WindowPtr window)
  161. {
  162.     NotifyCancel();
  163.  
  164.     if (IsAppWindow(window)) {
  165.         SetPort(window);
  166.         DoCtlActivate(window);
  167.         DoDrawFrame(window);            /* Redraw window scrollbars and growIcon, if any. */
  168.         BeginContent(window);
  169.         DoDrawControls(window, true);    /* Redraw content scrollbars. */
  170.         EndContent(window);
  171.     }
  172. }
  173.  
  174.  
  175.  
  176.